package com.github.shiqiyue.learn.elasticjob;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
 *
 * @author wenyao.wu
 * @date 2019/2/3
 */
public class MyJob implements SimpleJob {

    private static final Logger logger = LoggerFactory.getLogger(MyJob.class);

    @Override
    public void execute(ShardingContext shardingContext) {
        logger.info("开始执行作业:{}, 任务ID: {}", shardingContext.getJobName(), shardingContext.getTaskId());
        try {
            Thread.sleep(10000);
        } catch (Exception exception) {
            logger.error("异常！！执行作业:" + shardingContext.getJobName() + ", 任务ID: " + shardingContext.getTaskId(), exception);
        } finally {
            logger.info("结束执行作业:{}, 任务ID: {}", shardingContext.getJobName(), shardingContext.getTaskId());
        }


    }
}
